from rest_framework import serializers
from .models import *

# 优惠券类型序列化器
class CouponTypeSer(serializers.ModelSerializer):

    class Meta:
        model = CouponType
        fields = "__all__"


# 优惠券序列化器
class CouponSer(serializers.ModelSerializer):

    # 商品名字
    sku_name = serializers.SerializerMethodField()

    def get_sku_name(self,obj):
        return obj.good.name

    class Meta:
        model = Coupon
        fields = "__all__"
